<template>
  <div>
    <el-switch
      style="display: block"
      v-model="value"
      active-color="#13ce66"
      inactive-color="#ff4949"
      active-text="启用"
      inactive-text="禁用"
      active-value="y"
      inactive-value="n"
      @change="changeValue"
      :disabled="mydisabled"
    >
    </el-switch>
  </div>
</template>
<script>
export default {
  //status 就是父组件传入的y或者n的值
  //mydisabled 由父组件来控制 开关是否可点
    props:['mystatus','mydisabled'],
    data() {
      return {
        value: this.mystatus
      }
    },
    //子组件值的动态切换
    watch:{
      mystatus:function(newValue,oldValue){
          this.value=newValue
      }
    },
    methods:{
      changeValue(){
        this.$emit('changeSwitch',this.value)
        this.$emit('changeSwitchFindLike',this.value)
      }
    }
};
</script>